void change(char arr[], int left, int right,int sz)
{
    while (left <= right)
    {
        char x = arr[left];
        arr[left] = arr[right];
        arr[right] = x;
        left++; right--;
    }
    for (int i = 0; i < sz+1; i++)
    {
        if (arr[i] == ' '|| arr[i] == '\0')
        {
            for (int z = i-1; z >= 0; z--)
            {
                if (arr[z] == ' ')
                {
                    right = i-1; left = z + 1;
                    while (left <= right)
                    {
                        char x = arr[left];
                        arr[left] = arr[right];
                        arr[right] = x;
                        left++; right--;
                    }
                    break;
                }
                if (z == 0)
                {
                    right = i-1; left = 0;
                    while (left <= right)
                    {
                        char x = arr[left];
                        arr[left] = arr[right];
                        arr[right] = x;
                        left++; right--;
                    }
                    break;
                }
            }
        }
        
    }
}

int main()
    {
    char arr[101] = { 0 };
    gets(arr);
    int sz = strlen(arr);
    int left = 0; int right = sz-1;
    change(arr,left,right,sz); 
    for (int i = 0; i < sz; i++)
    {
        printf("%c", arr[i]);
    }
    return 0;
}
